Create a bounce loader animation.
HTML CODE:
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Pure CSS for circular animation</title>
<link href="~/css/style.css" rel="stylesheet" />
</head>
<body>
<div class="bouncing-loader">
<div></div>
<div></div>
<div></div>
</div>
</body>
</html>
CSS CODE:
@keyframes bouncing-loader {
from {
opacity: 1;
transform: translateY(0);
}
to {
opacity: 0.1;
transform: translateY(-1rem);
}
}
.bouncing-loader {
display: flex;
justify-content: center;
}
.bouncing-loader > div {
width: 1rem;
height: 1rem;
margin: 3rem 0.2rem;
background: #8385aa;
border-radius: 50%;
animation: bouncing-loader 0.6s infinite alternate;
}
.bouncing-loader > div:nth-child(2) {
animation-delay: 0.2s;
}
.bouncing-loader > div:nth-child(3) {
animation-delay: 0.4s;
}
Description
Note:1rem
Usually it is16px
.
@keyframes
An animation with two states is defined in which the elements are changedopacity
and usedtransform: translateY()
on a 2D planetransform: translateY()
..bouncing-loader
Is the parent container of the bounce circle, usedisplay: flex
andjustify-content: center
place them in a central position..bouncing-loader > div
, the three children of the parentdiv
as a style.div
The width and height are1rem
used toborder-radius: 50%
change them from square to round.margin: 3rem 0.2rem
Specify the top/bottom margin of each circle as the3rem
left/right margin0.2rem
so that they do not directly touch each other, giving them some breathing space.animation
Is an abbreviation attribute for various animation properties: useanimation-name
,animation-duration
,animation-iteration-count
,animation-direction
.nth-child(n)
The target is the nth child of its parent element.animation-delay
Used for the second and third respectivelydiv
, so that each element does not start the animation at the same time.
Post your comments / questions
Recent Article
- How to create custom 404 error page in Django?
- Requested setting INSTALLED_APPS, but settings are not configured. You must either define..
- ValueError:All arrays must be of the same length - Python
- Check hostname requires server hostname - SOLVED
- How to restrict access to the page Access only for logged user in Django
- Migration admin.0001_initial is applied before its dependency admin.0001_initial on database default
- Add or change a related_name argument to the definition for 'auth.User.groups' or 'DriverUser.groups'. -Django ERROR
- Addition of two numbers in django python
Related Article